package com.goldcontrol.cloudweb.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.goldcontrol.cloudweb.model.Info;
import com.goldcontrol.cloudweb.model.ProjectRepair;
import com.goldcontrol.cloudweb.model.ProjectRepairRecord;
import com.goldcontrol.cloudweb.model.TemplateMsgConstant;
import com.goldcontrol.cloudweb.model.alarm.AlarmTemplateMsgFactory;
import com.goldcontrol.cloudweb.service.ApiService;
import com.goldcontrol.cloudweb.service.InfoService;
import com.goldcontrol.cloudweb.service.RepairService;
import com.goldcontrol.cloudweb.util.MD5Util;
import com.goldcontrol.cloudweb.util.StringUtil;
import com.goldcontrol.cloudweb.weixin.service.WeixinServiceApi;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;

@Controller
@RequestMapping("/info")
public class InfoController {

    private static Logger logger = LoggerFactory.getLogger(InfoController.class);

    @Autowired
    InfoService infoService;

    @RequestMapping(value = "/get",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String get(){
        Info info = infoService.getCompanyInfo();
        return JSON.toJSONString(info);
    }

    @RequestMapping(value = "/update",produces = "application/json;charset=utf-8")
    @ResponseBody
    public String get(@RequestBody Info info){
        infoService.updateCompanyInfo(info);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("isOk",true);
        return jsonObject.toJSONString();
    }

}
